import 'package:flutter/material.dart';

enum Option{
A,B,C
}

class BottomSheetDemo extends StatefulWidget {
  @override
  _BottomSheetDemoState createState() => _BottomSheetDemoState();
}
class _BottomSheetDemoState extends State<BottomSheetDemo> {
  String bottomChoice = 'Nothing';
  final _bottomSheetScaffoldKey = GlobalKey<ScaffoldState>();
  _openBottomSheet(){
     _bottomSheetScaffoldKey
     .currentState
     .showBottomSheet((BuildContext context){
       return BottomAppBar(
              child: Container(
                height: 100,
                width: double.infinity,
                padding: EdgeInsets.all(10),
                child: Row(
                    children: <Widget>[
                      Icon(Icons.pause_circle_filled),
                      SizedBox(width:10),
                      Text('01:30-04:40'),
                      Expanded(child: Text('Fix you coldpay',textAlign: TextAlign.right,)),
                    ],
                ),
              ),
       );
     },
     );
  }

    Future _openModelBottomSheet() async{
    final choice =  await showModalBottomSheet(
      context: context, 
      builder: (BuildContext context){
        return Container(
            height: 200,
            child: Column(
              children:<Widget>[
               ListTile(
                 title:Text('Option A'),
                 onTap:(){
                   Navigator.pop(context,Option.A);
                 },
               ),
               ListTile(
                 title:Text('Option B'),
                 onTap:(){
                   Navigator.pop(context,Option.B);
                 },
                 ),
               ListTile(
                 title:Text('Option C'),
                 onTap:(){
                   Navigator.pop(context,Option.C);
                 },
                 ),
              ]
            ),

        );
      }
    );
   
   switch (choice) {
     case Option.A:
       setState(() {
         bottomChoice = 'A';
       });
       break;
       case Option.B:
       setState(() {
         bottomChoice = 'B';
       });
       break;
       case Option.C:
       setState(() {
         bottomChoice = 'C';
       });
       break;
     default:
   }

  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      key: _bottomSheetScaffoldKey,
        appBar: AppBar(
          title:Text('BottomSheetDemo'),
          elevation: 0.0,
        ),
         body: Container(
         padding: EdgeInsets.all(100),
         child: Column(
         mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[ 
          Text('youe choice is $bottomChoice'),
          SizedBox(height:20),
           RaisedButton(
             onPressed:_openBottomSheet,
             child: Text('Open the BottomSheet'),
             ),
             RaisedButton(
             onPressed:_openModelBottomSheet,
             child: Text('Open the penModelBottomSheet'),
             )
          ],
         ),
        ),
    );
  }
}